/**
 * @(#)DmChannelRetentDAOImpl.java 2016年5月25日
 * Copyright(C) 2015 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.dao.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.dao.IDmChannelRetentDAO;
import org.jsbd.boss.domian.ChannelMonitorExportInfo;
import org.jsbd.boss.domian.ChannelMonitorInfo;
import org.jsbd.boss.domian.ChannelRetentLogInfo;
import org.jsbd.boss.domian.ChannelRetentMonitorInfo;
import org.jsbd.boss.domian.channel.*;
import org.jsbd.boss.domian.statistics.ImsiretentResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.hziee.common.dbroute.BaseDAO;

/**
 * TODO 请加入本类的说明
 *
 * @author <a href="mailto:zhangbinghua@zhexinit.com" >zbh</a>
 * @version 1.0.0
 */
public class DmChannelRetentDAOImpl extends BaseDAO implements IDmChannelRetentDAO {
    public static final Logger LOGGER = LoggerFactory.getLogger(DmChannelRetentDAOImpl.class);

    @Override
    public List<RetentTaskVo> getDmChannelRetentBydate(String date, int limit, String maxexetime, String mark) {
        Map params = new HashMap();
        params.put("date", date.replaceAll("-", ""));
        params.put("limit", limit);
        params.put("maxexetime", maxexetime);
        params.put("mark", mark);
        return super.queryForList("qy_crack_channel_retent.SELECT_QY_DMCHANNELRETENT", params);

    }

    @Override
    public int getDmChannelCurrentRetentTotalCount(String date, String exetimes, String mark) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("date", date.replaceAll("-", ""));
        params.put("currentmaxexetime", exetimes);
        params.put("mark", mark);
        int total = (Integer) super.queryForCount("qy_crack_channel_retent.SELECT_QY_CURRENT_DMCLIENTINFO_TOTAL", params);
        return total;
    }

    @Override
    public List<RetentTaskVo> getDmChannelCurrentRetentBydate(String date, int limit, String currentMaxexetime, String mark) {
        Map params = new HashMap();
        params.put("date", date.replaceAll("-", ""));
        params.put("limit", limit);
        params.put("currentmaxexetime", currentMaxexetime);
        params.put("mark", mark);
        return super.queryForList("qy_crack_channel_retent.SELECT_QY_CURRENT_DMCHANNELRETENT", params);
    }

    @Override
    public List<RetentTaskVo> getRetentTask(RetentQueryVo queryVo) {
        return super.queryForList("qy_crack_channel_retent.SELECT_RETENT_MARK_DAY", queryVo);
    }

    @Override
    public List<RetentTaskVo> selectFileName(String day) {
        return super.queryForList("qy_crack_channel_retent.SELECT_RETENT_FILE_DAY", day);
    }

    @Override
    public List<ApkTaskInfo> selectCountNewTask(TaskQueryVo queryVo) {
        return super.queryForList("qy_crack_channel_retent.SELECT_COUNT_NEW_TASK", queryVo);
    }

    @Override
    public List<ApkTaskInfo> selectCountRetentTask(TaskQueryVo queryVo) {
        return super.queryForList("qy_crack_channel_retent.SELECT_COUNT_RETENT_TASK", queryVo);
    }

    @Override
    public List<ApkTaskInfo> selectTotalNewTask(TaskQueryVo queryVo) {
        return super.queryForList("qy_crack_channel_retent.SELECT_COUNT_NEW_TASK_TOTAL", queryVo);
    }

    @Override
    public List<ChannelRetentLogInfo> getChannelRetentALLLog(ChannelRetentLogInfo channelRetentLogInfo) {
        return super.queryForList("qy_crack_channel_retent.SELECT_QY_CHANNELRETENT_ALL_LOG", channelRetentLogInfo);

    }

    @Override
    public List<ChannelRetentLogInfo> getChannelRetentLog(ChannelRetentLogInfo channelRetentLogInfo) {
        return super.queryForList("qy_crack_channel_retent.SELECT_QY_CHANNELRETENT_LOG", channelRetentLogInfo);
    }

    @Override
    public int getDmChannelRetentSuccessCount(String date, String mark) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("date", date.replaceAll("-", ""));
        params.put("mark", mark);
        int total = (Integer) super.queryForCount("qy_crack_channel_retent.SELECT_QY_DMCLIENTINFO_SUCCESS_TOTAL", params);
        return total;
    }

    @Override
    public int selectSuccessMark(String mark) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("mark", mark);
        params.put("currentDate", edu.hziee.common.lang.DateUtil.formatDate(new Date(), "yyyyMMdd"));
        return super.queryForCount("qy_channelapk_limit.GET_CHANNELAPK_SUCCESS_BYMARK", params);
    }

    @Override
    public int getDmChannelCurrentRetentSuccessCount(String date, String exetimes, String mark) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("date", date.replaceAll("-", ""));
        params.put("currentmaxexetime", exetimes);
        params.put("mark", mark);
        int total = (Integer) super.queryForCount("qy_crack_channel_retent.SELECT_QY_CURRENT_DMCLIENTINFO_SUCCESS", params);
        return total;
    }

    @Override
    public List<ChannelRetentLogInfo> selectChannelRetentLogOfDay(ChannelRetentLogInfo channelRetentLogInfo) {
        return super.queryForList("qy_crack_channel_retent.SELECT_CHANNELRETENT_LOG_DAY", channelRetentLogInfo);
    }

    @Override
    public Integer updateExecTimesOfDay(String tabledate) {
        return super.update("qy_crack_channel_retent.UPDATE_TIMES_DAY", tabledate);
    }

    @Override
    public List<ChannelMonitorInfo> getChannelMonitorInfo(String time) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("time", time);
        params.put("currentDate", time.replaceAll("-", "").substring(0, 8));
        return super.queryForList("qy_crack_channel_retent.SELECT_QY_CHANNEL_MONITOR", params);
    }

    @Override
    public List<ChannelRetentMonitorInfo> getChannelRetentMonitorInfo(String date) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("currentDate", date);
        return super.queryForList("qy_crack_channel_retent.SELECT_QY_CHANNELRETENT_MONITOR", params);
    }

    @Override
    public int getChannelPlanRetentInfo(String mark, String date) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("mark", mark);
        params.put("currentDate", date);
        return super.queryForCount("qy_crack_channel_retent.SELECT_QY_CHANNELRETENT_NUM", params);

    }

    @Override
    public List<ChannelMonitorExportInfo> getChannelMonitorExportInfo(String time, String date, String yesterday) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("time", time);
        params.put("yesterday", yesterday);
        params.put("currentDate", date);
        return super.queryForList("qy_crack_channel_retent.SELECT_QY_CHANNEL_MONITOR_FOR_EXPORT", params);
    }

    @Override
    public List<Map<String, Object>> getMarkPhoneRateFromRetent(Map<String, Object> conditionMap) {
        return super.queryForList("qy_crack_channel_retent.get_mark_imsiretent_phone_rate", conditionMap);
    }

    @Override
    public List<ApkTaskInfo> selectReadNewTaskPay(TaskQueryVo queryVo) {
        return super.queryForList("qy_crack_channel_retent.SELECT_COUNT_READ_PAY_NUM", queryVo);
    }

    @Override
    public RetentTaskVo selectTaskInfo(RetentTaskVo taskInfo) {
        return (RetentTaskVo) super.queryForObject("qy_crack_channel_retent.SELECT_TASK_INFO", taskInfo);
    }

    @Override
    public List<String> getAllTableByTableName(String tableName) {
        return super.queryForList("qy_crack_channel_retent.SELECT_ALL_TABLE_BY_NAME", tableName);
    }

    @Override
    public List<ImsiretentResultVo> selectByMark(ImsiretentResultVo imsiretent) {
        return super.queryForList("qy_crack_channel_retent.SELECT_BY_TABLE_AND_MARK", imsiretent);
    }

    @Override
    public void batchDelete(List<RetentTaskVo> records) {
        super.batchUpdate("qy_crack_channel_retent.DELETE_RETENT", records);
    }


    @Override
    public int updateRetent(RetentTaskVo taskVo) {
        return super.update("qy_crack_channel_retent.UPDATE_RETENT_FILES", taskVo);
    }


    @Override
    public void insert(RetentTaskVo taskVo) {
        super.insert("qy_crack_channel_retent.INSERT_QY_DM_CHANNEL_IMSIRETENT", taskVo);
    }

    @Override
    public void insertLog(RetentTaskVo taskVo) {
        super.insert("qy_crack_channel_retent.INSERT_RETENT_LOG", taskVo);
    }

    @Override
    public int updateRetentTimes(RetentTaskVo retentTaskVo) {
        return super.update("qy_crack_channel_retent.UPDATE_RETENT_EXTIMES", retentTaskVo);
    }

}
